import Vue from 'vue'
import VueRouter from 'vue-router'
//import HelloWorld from '@/components/HelloWorld'
import Login from '@/views/Login'
import register from '@/views/wh/register'
import InvestmentPolicy from '@/views/wh/InvestmentPolicy'
import InvestmentProcess from '@/views/wh/InvestmentProcess'
import InvestmentAdvisory from '@/views/wh/InvestmentAdvisory'
import addInvestmentPolicy from '@/views/wh/addInvestmentPolicy'
import addInvestmentProcess from '@/views/wh/addInvestmentProcess'
import addInvestmentAdvisory from '@/views/wh/addInvestmentAdvisory'
import updateInvestmentPolicy from '@/views/wh/updateInvestmentPolicy'
import updateInvestmentProcess from '@/views/wh/updateInvestmentProcess'
import updateInvestmentAdvisory from '@/views/wh/updateInvestmentAdvisory'
import HomeStyle from '@/views/wh/HomeStyle'
import addHomeStyle from '@/views/wh/addHomeStyle'
import updateHomeStyle from '@/views/wh/updateHomeStyle'
import StyleShow from '@/views/wh/StyleShow'
import addStyleShow from '@/views/wh/addStyleShow'
import updateStyleShow from '@/views/wh/updateStyleShow'
import VolunteerService from '@/views/wh/VolunteerService'
import addVolunteerService from '@/views/wh/addVolunteerService'
import updateVolunteerService from '@/views/wh/updateVolunteerService'
import CommentEvaluation from '@/views/wh/CommentEvaluation'
import Head from '@/components/Head'
import Personnelinfo from '@/views/Personnelinfo'
import Gisdingwei from '@/views/Gisdingwei'
import Fankui from '@/views/Fankui'
import Advice from '@/views/Advice'
import Activities from '@/views/Activities'
import Sodality from '@/views/Sodality'
import Shouye from '@/views/Shouye'

// import Login from "../views/login/login";
import Contacts from "../views/contacts/contacts";
import Conversations from "../views/conversations/conversations";
import Indexx from "@/views/Indexx";
import Mine from "../views/mine/mine";
import CustomMessage from '../views/chat/customMessageForm/customMessageForm'
import Private from '../views/chat/privateChat/privateChat'
import Group from '../views/chat/groupChat/groupChat'



// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [

    {
        path: '/',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'register',
        component: register
    },

    {
        path: '/Head',
        name: 'Head',
        redirect: '/Shouye',
        component: Head,
        children: [{
            path: '/InvestmentPolicy',
            name: 'InvestmentPolicy',
            component: InvestmentPolicy
        },
        {
            path: '/addInvestmentPolicy',
            name: 'addInvestmentPolicy',
            component: addInvestmentPolicy
        }, {
            path: '/updateInvestmentPolicy',
            name: 'updateInvestmentPolicy',
            component: updateInvestmentPolicy
        }, {
            path: '/InvestmentProcess',
            name: 'InvestmentProcess',
            component: InvestmentProcess
        }, {
            path: '/addInvestmentProcess',
            name: 'addInvestmentProcess',
            component: addInvestmentProcess
        }, {
            path: '/updateInvestmentProcess',
            name: 'updateInvestmentProcess',
            component: updateInvestmentProcess
        }, {
            path: '/InvestmentAdvisory',
            name: 'InvestmentAdvisory',
            component: InvestmentAdvisory
        }, {
            path: '/addInvestmentAdvisory',
            name: 'addInvestmentAdvisory',
            component: addInvestmentAdvisory
        }, {
            path: '/updateInvestmentAdvisory',
            name: 'updateInvestmentAdvisory',
            component: updateInvestmentAdvisory
        }, {
            path: '/HomeStyle',
            name: 'HomeStyle',
            component: HomeStyle
        }, {
            path: '/addHomeStyle',
            name: 'addHomeStyle',
            component: addHomeStyle
        }, {
            path: '/updateHomeStyle',
            name: 'updateHomeStyle',
            component: updateHomeStyle
        }, {
            path: '/StyleShow',
            name: 'StyleShow',
            component: StyleShow
        }, {
            path: '/addStyleShow',
            name: 'addStyleShow',
            component: addStyleShow
        }, {
            path: '/updateStyleShow',
            name: 'updateStyleShow',
            component: updateStyleShow
        }, {
            path: '/VolunteerService',
            name: 'VolunteerService',
            component: VolunteerService
        }, {
            path: '/addVolunteerService',
            name: 'addVolunteerService',
            component: addVolunteerService
        }, {
            path: '/updateVolunteerService',
            name: 'updateVolunteerService',
            component: updateVolunteerService
        },{
            path: '/CommentEvaluation',
            name: 'CommentEvaluation',
            component: CommentEvaluation
        }, {
                path: '/Personnelinfo',
                name: 'Personnelinfo',
                component: Personnelinfo
            },
            {
                path: '/Gisdingwei',
                name: 'Gisdingwei',
                component: Gisdingwei
            },
            {
                path: '/Fankui',
                name: 'Fankui',
                component: Fankui
            },
            {
                path: '/Advice',
                name: 'Advice',
                component: Advice
            },
            {
                path: '/Activities',
                name: 'Activities',
                component: Activities
            },
            {
                path: '/Sodality',
                name: 'Sodality',
                component: Sodality
            },
            {
                path: '/Shouye',
                name: 'Shouye',
                component: Shouye
            },
            {
                path: '/customMessage',
                name: 'customMessage',
                component: CustomMessage
            },
            {
                path: '/private',
                name: 'private',
                component: Private
            },
            {
                path: '/group',
                name: 'group',
                component: Group
            },
            {
                path: '/indexx',
                name: 'indexx',
                redirect: '/conversations',
                component: Indexx,
                children: [
                    {
                        path: '/conversations',
                        name: 'conversations',
                        component: Conversations,
                    },
                    {
                        path: '/contacts',
                        name: 'contacts',
                        component: Contacts
                    },
                    {
                        path: '/mine',
                        name: 'mine',
                        component: Mine
                    }
                ]
            }]
    }

]

const router = new VueRouter({
    mode: 'history',
    routes
})


// router.beforeEach((to, from, next) => {
//   // 我在这里模仿了一个获取用户信息的方法
//   const isLogin = sessionStorage.getItem('user')
//   if (isLogin) {
//     // 如果用户信息存在则往下执行。
//     next()
//   } else {
//     // 如果用户token不存在则跳转到login页面
//     if (to.path === '/login') {
//       next()
//     } else {
//       next('/login')
//     }
//   }
// })


export default router
